package com.example.origin.spider.webmagic;

import com.example.origin.spider.properties.ProcessorProperties;
import us.codecraft.webmagic.Request;
import us.codecraft.webmagic.downloader.Downloader;
import us.codecraft.webmagic.downloader.HttpClientDownloader;

public class HttpClientProcessor extends AbstractProcessor {
    @Override
    public Request createRequest(ProcessorProperties properties) {
        Request request = new Request();
        request.setUrl(properties.getUrl());
        request.setCharset(properties.getCharset());
        setHeader(request, "User-Agent",properties.getUserAgent());
        setHeader(request, "Cookie",properties.getCookie());
        return request;
    }

    @Override
    public Downloader creaeteDownloader(ProcessorProperties properties) {
        return new SimpleHttpClientDownloader();
    }
}
